export default {
	namespaced: true,
	state: {
		list: []
	},
	getters: {
		isCollect(state) {
			return function(item) {
				return state.list.some(v => v._id === item._id)
			}
		}
	},
	mutations: {
		switchCollect(state, payload) {
			const item = state.list.find(v => v._id === payload._id);
			
			if(item) {
				state.list = state.list.filter(v => v._id !== payload._id)
			} else {
				state.list.push(payload)
			}
			
			console.log(state.list)
		},
	}
}